package com.uploadtest.jiaotizhixing;

import java.util.concurrent.CountDownLatch;
 
public class CountDownLatchTest {
    private static CountDownLatch c1 = new CountDownLatch(1);
    private static CountDownLatch c2 = new CountDownLatch(1);
    public static void main(String[] args) {

        final char arrayA[] = "1234567".toCharArray();
        final char arrayB[] = "ABCDEFG".toCharArray();
 
        Runnable runnable = () -> {

                for (char charA : arrayA) {
                    System.out.print(charA);
                    c1.countDown();
                }

 
        };
        Runnable runnable1 = () -> {
                for (char charB : arrayB) {
                    try {
                        c1.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.print(charB);
                }
        };
        new Thread(runnable).start();
        new Thread(runnable1).start();
    }
}